package com.bawei.bydayzg_two.adapter

import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.bawei.base.bean.CartGoreyResultItem
import com.bawei.bydayzg_two.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder

class CateTwoAdapter:BaseQuickAdapter<CartGoreyResultItem,BaseViewHolder>(R.layout.item_cate_two) {
    override fun convert(holder: BaseViewHolder, item: CartGoreyResultItem) {
        holder.setText(R.id.cateTwo_tv,"----------${item.name}--------")
        //在适配器内部给rv赋值  ==   类似在页面中的赋值
        val rv = holder.getView<RecyclerView>(R.id.cateTwo_rv)
        //定义适配器并且绑定
        val childAdapter = ChildAdapter()
        childAdapter.data.addAll(item.child)
        //
        rv.adapter = childAdapter
        rv.layoutManager = GridLayoutManager(context,3)
    }
}